package com.utils;

import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

public class ServerConf
{
    private ServerConf()
    {
        
    }
    private static Properties conf;
    static
    {
        conf = new Properties();
        InputStream in = ServerConf.class.getResourceAsStream( "/ServerConf.properties" );
        try
        {
            conf.load( in );
            in.close();
        }
        catch( IOException e )
        {
            e.printStackTrace();
        }
        
    }
    
    private static ServerConf instance = new ServerConf();
    
    public static ServerConf getInstance()
    {
        return instance;
    }

    
    public boolean isUseDataSource()
    {
        return "true".equals( conf.getProperty( "useDataSource" ) );
    }
    
    public String getDsName()
    {
        return conf.getProperty( "dsName" );
    }
    
    public String getDsUrl()
    {
        return conf.getProperty( "dsUrl" );
    }
    
    public boolean isUseWeblogic()
    {
        return "true".equals( conf.getProperty( "useWeblogic" ) );
    }
    
    public String getAddress()
    {
        if(isUseWeblogic()) return conf.getProperty( "weblogicAddress" );
        else return conf.getProperty( "tomcatAddress" );
    }
    
    public String getProperty( String propertyName )
    {
        return conf.getProperty( propertyName );
    }

}
